package com.sxt.test;

import java.util.Set;

import org.hibernate.Session;
import org.junit.Test;

import com.sxt.entity.City;
import com.sxt.entity.User;
import com.sxt.factory.HibernateSessionFactory;

public class OneToMany {
	/**
	 * 一对多查询
	 */
	@Test
	public void test1() {
		Session session = HibernateSessionFactory.getSession();
		City city = (City) session.get(City.class, 1);
		System.out.println(city.getName());
		Set<User> users = city.getUsers();
		for (User user : users) {
			System.out.print(user.getUname() + " ");
		}
		session.close();
	}
}
